package com.ruoyi.web.controller.common;

import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.service.ISysConfigService;
import com.ruoyi.system.service.ISysMenuService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author tianl
 * @date 2025/1/7
 * @description:
 */
@RestController
@RequestMapping("/api")
public class ApiController extends BaseController {
    @Autowired
    private ISysConfigService configService;
    @Autowired
    private ISysMenuService menuService;

    @Anonymous
    @GetMapping(value = "/title")
    public AjaxResult title() {
        String title = configService.selectConfigByKey("sys.title");
        return success("ok", StringUtils.isNotBlank(title) ? title : "管理系统");
    }

    @Anonymous
    @GetMapping(value = "/router")
    public AjaxResult router(String comp) {
        String path = menuService.selectPathByComp(comp);
        return success("ok", path);
    }
}
